class CameraUtil {
    open = () => {
        return new Promise((resolve, reject) => {
            if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
                navigator.mediaDevices
                  .getUserMedia({ video: true, audio: true })
                //   .getUserMedia({ video: true })
                  .then(function (stream) {
                    resolve(stream)
                  })
                  .catch(function (error) {
                    console.log(error)
                    reject({
                        error,
                        code: -1
                    })
                  })

              }
              else {
                console.log('no device');
                
                reject('fail')
              }
        })
    }
}

export { CameraUtil }